package com.baor.controller;


import com.baor.domain.RoleVo;
import com.baor.service.RoleService;
import com.baor.utils.AjaxResult;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;
import java.util.Objects;

@RestController
@RequestMapping("/role")
public class RoleController {

    @Autowired
    private RoleService roleService;

    @RequestMapping("/roleList")
    public AjaxResult<?> roleList(@RequestBody RoleVo vo){
        return roleService.roleList(vo);
    }

    @RequestMapping("/search")
    public AjaxResult<?> search(@RequestBody RoleVo vo){
        return roleService.search(vo);
    }

    @RequestMapping("/insert")
    public AjaxResult<?> insert(@RequestBody RoleVo vo){
        return roleService.insert(vo);
    }

    @RequestMapping("/update")
    public AjaxResult<?> update(@RequestBody RoleVo vo){
        return roleService.update(vo);
    }

    @RequestMapping("/delete")
    public AjaxResult<?> delete(@RequestBody RoleVo vo){
        return roleService.delete(vo.getRoleId());
    }

    @RequestMapping("/roleInfo")
    public AjaxResult<?> info(@RequestBody RoleVo vo){
        return roleService.info(vo.getRoleId());
    }

    @RequestMapping("/getMenus")
    public AjaxResult<?> getMenus(@RequestBody RoleVo vo){
        return roleService.getMenus(vo.getRoleId());
    }

    @RequestMapping("/chooseMenu")
    public AjaxResult<?> chooseMenu(@RequestBody Map<String, Object> map){
        return roleService.chooseMenu(map);
    }

    @RequestMapping("/updateMenus")
    public AjaxResult<?> updateMenus(@RequestBody Map<String,Object> map){
        return roleService.updateMenus(map);
    }

    @RequestMapping("/deleteMenus")
    public AjaxResult<?> deleteMenus(@RequestBody RoleVo vo){
        return roleService.deleteMenus(vo.getRoleId());
    }

}
